﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Streambolics.App;
using Streambolics.Web;

namespace Streambolics.Ha7Net.DemoApp
{
    public partial class MainForm : AppForm
    {
        private HttpQueryJobProcessor _Processor;
        private JobQueue<HttpQueryJob> _Queue;
        private Ha7NetSensorData _Data;

        public MainForm ()
        {
            InitializeComponent ();
            _Queue = new JobQueue<HttpQueryJob> ();
            _Processor = new HttpQueryJobProcessor ();
            _Processor.Attach (_Queue);

            _Data = new Ha7NetSensorData ("192.168.1.1", "EA3ERB");
            _Data.Attach (_Queue);
        }

        private void timer_Tick (object sender, EventArgs e)
        {
            double v;
            DateTime t;

            _Processor.Start ();

            if (_Data.GetRealTimeData (out v, out t))
            {
                label1.Text = "{0} : {1}".Format (v, t);
            }
        }
    }
}
